{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 安装faker模块\n",
    "[官方文档](https://faker.readthedocs.io/en/master/locales.html)<br>\n",
    "[知乎上对该模块的相关介绍](https://zhuanlan.zhihu.com/p/93598610)<br>\n",
    "**方法一(推荐！！！)**：搜索Anaconda prompt下载第三方模块faker<br>\n",
    "![Anaconda prompt](ana_prompt.png)<br>\n",
    "输入以下代码进行安装：**pip install faker**<br>\n",
    "**方法二**：打开命令指示符【输入cmd打开】安装faker模块<br>\n",
    "输入以下代码进行安装：**pip install faker**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 导入模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "from faker import Faker"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# 选择语言\n",
    "## 以下是常见的语言代号\n",
    "* 简体中文：zh_CN\n",
    "* 繁体中文：zh_TW\n",
    "* 美国英文：en_US\n",
    "* 英国英文：en_GB\n",
    "* 德文：de_DE\n",
    "* 日文：ja_JP\n",
    "* 韩文：ko_KR\n",
    "* 法文：fr_FR"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "#选择中文\n",
    "faker=Faker('zh_CN')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "# for循环生成数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "hidden": true
   },
   "outputs": [],
   "source": [
    "#选择语言\n",
    "index_list=[]\n",
    "name_list=[]\n",
    "job_list=[]\n",
    "address_list=[]\n",
    "datetime_list=[]\n",
    "company_list=[]\n",
    "phone_list=[]\n",
    "email_list=[]\n",
    "ip_list=[]\n",
    "#python enumerate函数会将每个元素及每个元素的索引列出\n",
    "for i,v in enumerate(range(500)):\n",
    "#     province=faker.province()\n",
    "#     city=faker.city()\n",
    "    name=faker.name()\n",
    "#     district=faker.district()\n",
    "    address=faker.address()\n",
    "    job=faker.job()\n",
    "    phone=faker.phone_number()\n",
    "    email=faker.free_email()\n",
    "    ip=faker.ipv4_public(network=False, address_class=None)\n",
    "#     street_name=faker.street_name()\n",
    "    datetime=faker.date(pattern=\"%Y-%m-%d\", end_datetime=None)\n",
    "    company=faker.company()\n",
    "    index_list.append(i)\n",
    "    name_list.append(name)\n",
    "    job_list.append(job)\n",
    "    address_list.append(address)\n",
    "    datetime_list.append(datetime)\n",
    "    company_list.append(company)\n",
    "    phone_list.append(phone)\n",
    "    email_list.append(email)\n",
    "    ip_list.append(ip)\n",
    "    #print(i,name,job,address ,datetime,company,phone,email,ip)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 将生成的数据表格化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>职业</th>\n",
       "      <th>居住地址</th>\n",
       "      <th>工作开始时间</th>\n",
       "      <th>公司</th>\n",
       "      <th>手机号码</th>\n",
       "      <th>邮箱</th>\n",
       "      <th>IP地址</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>孙丽</td>\n",
       "      <td>大学/大专应届毕业生</td>\n",
       "      <td>天津市南京县长寿李街l座 165661</td>\n",
       "      <td>1990-04-09</td>\n",
       "      <td>维旺明网络有限公司</td>\n",
       "      <td>13957405892</td>\n",
       "      <td>ping75@gmail.com</td>\n",
       "      <td>83.18.120.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>简勇</td>\n",
       "      <td>测试工程师</td>\n",
       "      <td>香港特别行政区重庆县白云大冶街j座 573130</td>\n",
       "      <td>1998-06-16</td>\n",
       "      <td>华成育卓科技有限公司</td>\n",
       "      <td>15305369990</td>\n",
       "      <td>vyi@yahoo.com</td>\n",
       "      <td>190.169.143.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>董芳</td>\n",
       "      <td>生物工程/生物制药</td>\n",
       "      <td>宁夏回族自治区杭州市上街王路s座 413936</td>\n",
       "      <td>1987-09-17</td>\n",
       "      <td>太极传媒有限公司</td>\n",
       "      <td>13263016099</td>\n",
       "      <td>mlai@hotmail.com</td>\n",
       "      <td>110.106.134.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>谢兰英</td>\n",
       "      <td>市场/营销/拓展专员</td>\n",
       "      <td>新疆维吾尔自治区兰英市合川萧路T座 819807</td>\n",
       "      <td>2016-12-21</td>\n",
       "      <td>戴硕电子科技有限公司</td>\n",
       "      <td>15165445159</td>\n",
       "      <td>weikang@gmail.com</td>\n",
       "      <td>144.83.224.236</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>龚莹</td>\n",
       "      <td>签证专员</td>\n",
       "      <td>浙江省静市涪城万路o座 393506</td>\n",
       "      <td>2017-11-11</td>\n",
       "      <td>九方科技有限公司</td>\n",
       "      <td>14782251973</td>\n",
       "      <td>jiexie@gmail.com</td>\n",
       "      <td>150.63.133.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>李桂花</td>\n",
       "      <td>市场助理</td>\n",
       "      <td>四川省香港县永川柳州街B座 152294</td>\n",
       "      <td>2016-06-05</td>\n",
       "      <td>同兴万点传媒有限公司</td>\n",
       "      <td>18753742460</td>\n",
       "      <td>renfang@hotmail.com</td>\n",
       "      <td>220.69.245.125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>谢勇</td>\n",
       "      <td>其他</td>\n",
       "      <td>新疆维吾尔自治区敏市浔阳沈阳路C座 897466</td>\n",
       "      <td>1980-05-26</td>\n",
       "      <td>浦华众城信息有限公司</td>\n",
       "      <td>13321517594</td>\n",
       "      <td>fjin@gmail.com</td>\n",
       "      <td>148.90.131.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>王超</td>\n",
       "      <td>质量管理/验货员(QA/QC)</td>\n",
       "      <td>云南省南京县淄川黄路C座 866944</td>\n",
       "      <td>2000-04-22</td>\n",
       "      <td>创联世纪信息有限公司</td>\n",
       "      <td>18888712397</td>\n",
       "      <td>leixiang@hotmail.com</td>\n",
       "      <td>136.164.79.198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>贺利</td>\n",
       "      <td>仪器/仪表/计量分析师</td>\n",
       "      <td>河南省海燕市兴山刘路U座 621789</td>\n",
       "      <td>1992-02-05</td>\n",
       "      <td>黄石金承网络有限公司</td>\n",
       "      <td>15340392554</td>\n",
       "      <td>zhongjie@yahoo.com</td>\n",
       "      <td>68.39.142.101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>陈玉梅</td>\n",
       "      <td>其他</td>\n",
       "      <td>黑龙江省淑华县新城郑州路d座 405490</td>\n",
       "      <td>1984-04-20</td>\n",
       "      <td>信诚致远网络有限公司</td>\n",
       "      <td>15278072924</td>\n",
       "      <td>suyan@gmail.com</td>\n",
       "      <td>172.216.194.44</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      姓名               职业                      居住地址      工作开始时间          公司  \\\n",
       "0     孙丽       大学/大专应届毕业生       天津市南京县长寿李街l座 165661  1990-04-09   维旺明网络有限公司   \n",
       "1     简勇            测试工程师  香港特别行政区重庆县白云大冶街j座 573130  1998-06-16  华成育卓科技有限公司   \n",
       "2     董芳        生物工程/生物制药   宁夏回族自治区杭州市上街王路s座 413936  1987-09-17    太极传媒有限公司   \n",
       "3    谢兰英       市场/营销/拓展专员  新疆维吾尔自治区兰英市合川萧路T座 819807  2016-12-21  戴硕电子科技有限公司   \n",
       "4     龚莹             签证专员        浙江省静市涪城万路o座 393506  2017-11-11    九方科技有限公司   \n",
       "..   ...              ...                       ...         ...         ...   \n",
       "495  李桂花             市场助理      四川省香港县永川柳州街B座 152294  2016-06-05  同兴万点传媒有限公司   \n",
       "496   谢勇               其他  新疆维吾尔自治区敏市浔阳沈阳路C座 897466  1980-05-26  浦华众城信息有限公司   \n",
       "497   王超  质量管理/验货员(QA/QC)       云南省南京县淄川黄路C座 866944  2000-04-22  创联世纪信息有限公司   \n",
       "498   贺利      仪器/仪表/计量分析师       河南省海燕市兴山刘路U座 621789  1992-02-05  黄石金承网络有限公司   \n",
       "499  陈玉梅               其他     黑龙江省淑华县新城郑州路d座 405490  1984-04-20  信诚致远网络有限公司   \n",
       "\n",
       "            手机号码                    邮箱            IP地址  \n",
       "0    13957405892      ping75@gmail.com    83.18.120.44  \n",
       "1    15305369990         vyi@yahoo.com  190.169.143.22  \n",
       "2    13263016099      mlai@hotmail.com  110.106.134.59  \n",
       "3    15165445159     weikang@gmail.com  144.83.224.236  \n",
       "4    14782251973      jiexie@gmail.com   150.63.133.78  \n",
       "..           ...                   ...             ...  \n",
       "495  18753742460   renfang@hotmail.com  220.69.245.125  \n",
       "496  13321517594        fjin@gmail.com    148.90.131.4  \n",
       "497  18888712397  leixiang@hotmail.com  136.164.79.198  \n",
       "498  15340392554    zhongjie@yahoo.com   68.39.142.101  \n",
       "499  15278072924       suyan@gmail.com  172.216.194.44  \n",
       "\n",
       "[500 rows x 8 columns]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "df=pd.DataFrame({\n",
    "    \"姓名\":name_list,\n",
    "    \"职业\":job_list,\n",
    "    \"居住地址\":address_list,\n",
    "    \"工作开始时间\":datetime_list,\n",
    "    \"公司\":company_list,\n",
    "    \"手机号码\":phone_list,\n",
    "    \"邮箱\":email_list,\n",
    "    \"IP地址\":ip_list\n",
    "})\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 数据输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_excel('大量人员信息数据.xlsx')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
